package com.woniuxy.exceptionhandler;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author lg
 * @time 2020/07/06 00:27:15
 */
public class MyExceptiomHandlerReolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
                                         Object o, Exception e) {
         if(e instanceof UnauthorizedException){
             return new ModelAndView ("unauthorized");
         }
        return null;
    }
}
